// pages/story/story.js
import http from "../../common/http"
Page({

    /**
     * 页面的初始数据
     */
    data: {
        list: null,
        isShow:true
    },

    /**
     * 生命周期函数--监听页面加载
     */
    onLoad(options) {
        wx.showLoading({
          title: '加载中...',
        })
        let a = wx.getStorageSync('list');
        if (a) {
            this.setData({
                list: a,
                isShow:false
            });
            wx.hideLoading({
              success: (res) => {},
            })
        } else {
            let obj = {
                url: '/1700-1?showapi_appid=985280&showapi_sign=59608625ed8243edbb9de8740853d3f3'
            }
            http(obj).then(res => {
                wx.setStorageSync("list",res.data.showapi_res_body.storylist);
                this.setData({
                    list:res.data.showapi_res_body.storylist,
                    isShow:false
                });
                wx.hideLoading({
                    success: (res) => {},
                  })
            })
        }

    },
    change(e) {
        let index=e.detail.value
        let title = this.data.list[index].classify
        wx.navigateTo({
          url: '../list/list?classifyId='+this.data.list[index].classifyId+'&title='+title,
        })
    },
})